import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'
import './index.css'
import { BrowserRouter } from 'react-router-dom'
import './i18n/i18n'
import './utils/edgeEmergencyFix' // Edge浏览器应急修复
import './utils/edgeBrowserFix' // Edge浏览器兼容性修复
import { ConfigProvider, theme } from 'antd'
import AppRoutes from './routes'
import { MessageProvider } from './components/messageApi'

// 调试工具，仅在开发环境加载
if (process.env.NODE_ENV === 'development') {
  import('./utils/debugTools')
    .then(({ initDebugTools }) => {
      // 初始化调试工具
      initDebugTools()
    })
    .catch(err => {
      console.error('Failed to load debug tools:', err)
    })
}

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <BrowserRouter>
      <ConfigProvider
        theme={{
          algorithm: theme.darkAlgorithm,
          token: {
            colorPrimary: '#e75275',
          },
        }}
      >
        <MessageProvider>
      <App />
          <AppRoutes />
        </MessageProvider>
      </ConfigProvider>
    </BrowserRouter>
  </React.StrictMode>,
)
